﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using QMERP.Domain.Entities;

namespace QMERP.Infrastructure.EFCore.Mappings
{
    public class SalesProcessMapping : IEntityTypeConfiguration<SalesProcess>
    {
        public void Configure(EntityTypeBuilder<SalesProcess> builder)
        {
            builder.HasQueryFilter(x => x.IsEnable);
            builder.Property(x => x.Code).HasMaxLength(20);
            builder.Property(x => x.Name).HasMaxLength(50);
            builder.Property(x => x.SalesCode).HasMaxLength(100);
            builder.Property(x => x.SalesName).HasMaxLength(100);
            builder.Property(x => x.Price).HasPrecision(18, 2);
            builder.Property(x => x.Cost).HasPrecision(18, 2);
            builder.Property(x => x.IsCFUsable);
            builder.Property(x => x.IsKCUsable);
            builder.Property(x => x.Remark).IsRequired(false).HasMaxLength(500);

            builder.HasIndex(x => x.Id);
            builder.HasIndex(x => x.Code);
            builder.HasIndex(x => x.Name);
        }
    }
}
